﻿using System;
using System.Collections.Generic;
using System.Configuration;
using CoreLab.MySql;
using NENAData.Errors;
using NENAData.LINQ;
using System.Text;

namespace NENAData.MYSQL
{
    class MYSQLGroupMembership
    {

        public void AddGroupMembership(int intPNUID, string strWebsite)
        {
            try
            {

                StringBuilder strBuilder = new StringBuilder();

                strBuilder.Append("insert into ").Append(strWebsite).Append("_group_membership  (pn_gid, pn_uid)");
                strBuilder.Append("values ");
                strBuilder.Append("(@PNGID, @PNUID);");

                MySqlConnection MySqlCon = new MySqlConnection(ConfigurationManager.AppSettings["MYSQLConnectionString"]);
                MySqlCommand MySqlCom = new MySqlCommand(strBuilder.ToString(), MySqlCon);

                MySqlCom.Parameters.Add("@PNGID", "1");
                MySqlCom.Parameters.Add("@PNUID", intPNUID);

                MySqlCon.Open();
                MySqlCom.ExecuteNonQuery();
                MySqlCon.Close();
            }
            catch (Exception ex)
            {
                ErrHandler.WriteError(ex.Message);
                throw (ex);
            }
        }
    }
}
